<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/5/1
 * Time: 22:03
 */

namespace Lib\Api;


class OrganizationSettingApi extends UtilsApi {
    private static $modelName = 'OrganizationSetting';

    /** 获取结构设置列表
     * @param $where
     * @param int $page_num
     * @param int $page_size
     * @param string $filed
     * @return mixed
     */
    public static function getList($where, $page_num = 1, $page_size = 15, $filed = "*") {
        $list = parent::getList(OrganizationSettingApi::$modelName, $where, $page_num, $page_size, $filed);
        return $list;
    }

    /** 获取结构设置总数
     * @param $where
     * @return mixed
     */
    public static function getTotal($where) {
        $total = parent::getTotal(OrganizationSettingApi::$modelName, $where);
        return $total;
    }

    /** 获取结构设置信息
     * @param $where
     * @param $field
     * @return mixed
     */
    public static function getInfo($where, $field= "*") {
        $organizationSetting = parent::getInfo(OrganizationSettingApi::$modelName, $where, $field);
        return $organizationSetting;
    }

    /** 获取结构设置信息
     * @param $where
     * @param $left
     * @param $field
     * @return mixed
     */
    public static function getInfoByCondition($where, $left, $field= "*") {
        $model = M();
        $organizationSetting = $model->table('fs_organization_setting a')
            ->join($left)
            ->field($field)
            ->where($where)
            ->find();

        return $organizationSetting;
    }

    /** 添加结构设置
     * @param $data
     * @return mixed
     */
    public static function add($data) {
        $id = parent::add(OrganizationSettingApi::$modelName, $data);
        return $id;
    }

    /** 修改结构设置
     * @param $data
     * @return bool
     */
    public static function save($data) {
       $state = parent::save(OrganizationSettingApi::$modelName, $data);
        return $state;
    }

    /** 保存数据
     * @param $where
     * @param $data
     * @return bool
     */
    public static function saveByCondition($where, $data) {
        $model = M(OrganizationSettingApi::$modelName);
        return $model->where($where)->save($data);
    }

    /** 删除结构设置
     * @param $where
     */
    public static function delete($where) {
        parent::delete(OrganizationSettingApi::$modelName, $where);
    }
}